package com.medical.admin.hospital.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.medical.admin.hospital.common.vo.ComboVo;
import com.medical.admin.hospital.entity.Combo;
import com.medical.admin.hospital.entity.ComboType;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ComboMapper extends BaseMapper<Combo> {
    /**
     * 通过套餐名称查询套餐
     * @param comboName
     * @return
     */
    default Combo findByComboName(String comboName){
            LambdaQueryWrapper<Combo> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(comboName!=null,Combo::getComboName,comboName);
            return this.selectOne(queryWrapper);
    }

    /**
     * 动态分页查询
     * @param comboTypeId
     * @param comboName
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<ComboVo> pageList(@Param("comboTypeId") Long comboTypeId,
                           @Param("comboName") String comboName,
                           @Param("pageNum") int pageNum, @Param("pageSize") int pageSize);

    /*default Page<Combo> page(Long comboTypeId, String comboName, int pageNum, int pageSize){
        Page<Combo> page = new Page(pageNum,pageSize);
        LambdaQueryWrapper<Combo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Combo::getComboTypeId,comboTypeId)
                .eq(comboName!=null,Combo::getComboName,comboName);
        return this.selectPage(page,queryWrapper);
    };*/
};
